Repository navigation
Fix vendored gems breaking the Docker gem layer without a word (#2326) - #2425
Mikola Lysenko (mikolalysenko) merged 5 commits into
Conversation
Empty commit that opens the draft pull request for #2326. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQudUKeWbvpP6NwpQK
A vendored gem is a path gem under .socket/vendor/, so a Dockerfile that copies only the Gemfile pair before bundle install stops building (#2326). These tests ask the vendored close for a next step that names the missing COPY, and for none when the layer has the directory. They fail until the step is added. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQudUKeWbvpP6NwpQK Assisted-by: Claude Code:claude-fable-5-2
After a vendored run, the usual Dockerfile gem layer (COPY Gemfile Gemfile.lock, then bundle install) fails with "The path ... does not exist": the vendored gems are path gems under .socket/vendor/, which that step does not copy. Nothing said so. The vendored close now adds a next step when a Dockerfile or Containerfile in the project root runs bundle install in a stage that copied the Gemfile or its lock and neither the project nor .socket. It names the COPY to add, beside the copied Gemfile. The step is human output only: no event, code or exit status changes. The Ruby docs gain a section on vendored gems in a Docker build, and the contract describes the new step. Fixes #2326 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQudUKeWbvpP6NwpQK Assisted-by: Claude Code:claude-fable-5-2
Review of the Docker gem layer step found advice that could be wrong and layers it missed: - A Gemfile copied to a directory written without a slash (/app) gave a COPY into its parent. - Any source starting with .socket counted as the vendored gems (.socket/manifest.json, .socketrc), as did the flattening COPY *. - A stage built on an earlier stage started empty, so the pair or the fix made in a base stage was not seen. - An install in a RUN here-document, or spelled bin/bundle or bundler, was not seen, and a JSON-form COPY lost a path with a space. - gems.rb counted as the pair, though vendored mode refuses it. A RUN that sets BUNDLE_GEMFILE is left unjudged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQudUKeWbvpP6NwpQK Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview A new Docs ( Reviewed by Cursor Bugbot for commit 200f593. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. After a vendored run patches a Bundler gem, it reads a Risk: low. The reader can only add one line of advice and stays silent when it can't read the file or can't tell what the Dockerfile does. It cannot fail a run. Look here
Verified
Changes I made: none. Open questions: none. Minor: Generated by Claude Code |
One conflict, in docs/ecosystems.md: main added the agent-mode paragraphs to "Ruby gems: gems already installed" where this branch adds the section "Ruby gems: vendored gems in a Docker build". Both are kept, main's paragraphs first since they close the section above. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed the full diff at bb4df6b: the Docker gem layer hint prints only in human output after a non-dry-run vendored gem apply, and an unreadable Dockerfile cannot fail the run. No blocking defects.
Non-blocking notes (each only yields one wrong advice line)
docker_hints.rs:214-236: splitting on&,;and|loses command boundaries, soRUN mkdir -p /usr/local/bundle && install -d /xafter the Gemfile copy is read asbundle install.docker_hints.rs:144-157:RUN echo 1<<3is read as a here-document with terminator3, which hides a laterCOPY . ..vendor.rs:5394:gems > for_bazelcompares gem events with every event carrying the Bazel advisory code; a mixed run can keep the step silent.
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2326
Summary
After
scan --mode vendored(orvendor) patches a gem, the usual Dockerfile gem layer stops building, and nothing told the user:This PR makes the vendored run say so, and documents it. It changes human output and docs only: no file the run writes, no JSON, no event, no warning code and no exit status changes.
Next step. When the run vendored a gem for Bundler and a
DockerfileorContainerfilein the project root runsbundle installin a stage that copied theGemfileor its lock but not the project or.socket, theNext steps:block gains a third line:The
COPYit names follows the Gemfile's destination (/app/.socket/vendorafterCOPY Gemfile Gemfile.lock /app/).Docs.
docs/ecosystems.mdgains "Ruby gems: vendored gems in a Docker build" (the Bun section already documents this case for Bun), andCLI_CONTRACT.mddescribes the new step.Root cause
A vendored gem is a
path:gem under.socket/vendor/gem/, sobundle installneeds that directory wherever it runs. The gem layer thatrails newwrites copies only the Gemfile pair before the install. The vendored close named only the commit and the reinstall, and the Ruby docs did not mention Docker.How the Dockerfile is read
crates/socket-patch-cli/src/commands/docker_hints.rsis a small reader of one file's instructions. It is a heuristic that only ever adds one line of advice, and it is built to stay silent when it cannot tell:COPY/ADDofGemfile,Gemfile.lockorGemfile*from the build context, and a copy of.,.socket,.socket/vendoror.socket/vendor/gem; a stage built on an earlier one (FROM base AS build) starts from that stage's state;RUNthat callsbundle install(alsobin/bundle,bundler, a version selector, the JSON form, a here-document) with the pair copied and the vendored gems not;--chown,--link), the JSON form ofCOPY, CRLF files and comments;.dockerignore, skips aCOPY --from=, and does not judge aRUNwith a bind mount or one that setsBUNDLE_GEMFILE=.A gem committed for a rules_ruby hub of a Bazel workspace is not a
path:gem, so a run that vendored only such gems prints no step.Evidence
COPYfor therails newgem layervendor_gem_docker_layer::a_gem_layer_without_the_vendor_dir_gets_a_next_step(CLIvendorsuite)Containerfilevendor_gem_docker_layer::a_containerfile_is_read_toovendor_gem_docker_layer::a_layer_that_copies_the_vendor_dir_gets_no_stepcommands::docker_hints::testsRed before the fix (commit
76b490fholds the tests alone):Green on this branch:
cargo clippy --all-targetsreports errors in test files this PR does not touch (tests/prebuilt_common,tests/common,scan/discovery.rstests); they are there onmaintoo, and CI's clippy job does not lint test targets.That
COPY .socket/vendorbeside the pair makes a freshbundle installpass is what the existing fresh-checkout tests ofe2e_vendor_gem_buildcover; the failure without it is the measurement in #2326. I did not build a Docker image.Review
/code-review highran on the first push and returned 10 findings. Fixed in200f593, each with a unit test: a destination without a trailing slash, sources that only start with.socket,COPY *, stages built on earlier stages, here-documents,bin/bundleandbundler, the JSON form with a space in a path, andgems.rb(vendored mode refuses such a project, so it is no longer read as the pair).Not fixed, because each one only keeps the step silent or is rare, and a reader that is certain would need a real Dockerfile parser:
.socketputs it is not checked (COPY .socket /tmp/counts as the fix). Silent, not wrong.RUNleaves it unjudged, also a mount of one file. Silent, not wrong.bundle(install is its default command) is not seen as an install: after splitting the command line into words there is no telling it frombundlefollowed by the next command.RUN echo "… bundle install …"counts as an install, and so doesbundle install --gemfile=other. Matching--gemfileanywhere in the line silenced the stock Rails Dockerfile (bootsnap precompile --gemfile), so onlyBUNDLE_GEMFILE=is honored.Follow-ups
.dockerignorethat excludes.socketbreaks the build the same way; the docs say so, the run does not check it.https://claude.ai/code/session_011f9aeQudUKeWbvpP6NwpQK
Generated by Claude Code